package br.com.felipeab.dexter.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Classe DetailSolicitation
 * 
 * @author Felipe A. Braga <br>
 *         16/06/2012 16:33:09<br>
 * 
 */
@Entity
@Table(name = "tDetailSolicitation")
public class DetailSolicitation implements Serializable {

	private static final long serialVersionUID = 2263131040976209641L;

	private Long id;
	private String description;
	private Date date;
	private User userDetail;
	private Status statusOS;
	private ServiceOrder serviceOrder;

	public DetailSolicitation() {}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long codigo) {
		this.id = codigo;
	}

	@Column(name = "description", nullable = false, length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String descricao) {
		this.description = descricao;
	}

	@Column(name = "dateDtlSltn", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getDate() {
		return date;
	}

	public void setDate(Date data) {
		this.date = data;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "usrDetail", referencedColumnName = "id", nullable = false)
	public User getUserDetail() {
		return userDetail;
	}

	public void setUserDetail(User usuario) {
		this.userDetail = usuario;
	}

	@Column(name = "statusServiceOrder", nullable = false)
	@Enumerated(EnumType.STRING)
	public Status getStatusOS() {
		return statusOS;
	}

	public void setStatusOS(Status statusOS) {
		this.statusOS = statusOS;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idServiceOrder", referencedColumnName = "id", nullable = false)
	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DetailSolicitation other = (DetailSolicitation) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}
